package com.bwie.exdomain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;

/**
 * @Author: lrz
 * @Date: 2024/10/24 19:49
 * @Description:
 **/
@Data
@Document(indexName = "es_user",shards = 1,replicas = 0)
//indexName 索引的名字不要使用大写字母
//shards 分片数量
//replicas 副本数量
public class EsUser implements Serializable {
    @Id
    @Field(type = FieldType.Keyword)
    private Integer id;

    //Text 表示要分词,必须指定分词器
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String username;

    //Keyword 表示不分词 index 表示不搜索，仅存储
    @Field(type = FieldType.Keyword,index = false)
    private String password;

    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String phone;


    @JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GTM+8")
    @Field(type = FieldType.Date,format = DateFormat.custom,pattern = "yyyy-MM-dd HH:mm:ss")
    private Date time;

    @Field(type = FieldType.Keyword,index = false)
    private Integer typeId;
}
